<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>支付宝收银台</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <link rel="apple-touch-icon" href="/alipay/icon.ico">
    <link rel="shortcut icon" href="/alipay/icon.ico">
    <#if expire == 0>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.5/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/gh/jquery/jquery@3.2.1/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/jeromeetienne/jquery-qrcode@1.0/jquery.qrcode.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/mobile-detect/mobile-detect.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>

    <script type="text/javascript">
        var maxtime = 300;

        function CountDown() {
            if (maxtime >= 0) {
                minutes = Math.floor(maxtime / 60);
                seconds = Math.floor(maxtime % 60);
                hours = Math.floor(maxtime / 3600);
                document.all["minutes"].innerHTML = minutes + "分";
                document.all["seconds"].innerHTML = seconds + "秒";
                document.all["hours"].innerHTML = hours + "时";
                --maxtime;
            } else {
                clearInterval(time);
            }
        }

        time = setInterval("CountDown()", 1000);

        $(function () {
            var md = new MobileDetect(navigator.userAgent);
            var osStr = md.os()
            var qrUrl = "${codeUrl}";
            if (osStr == "iOS") {
                qrUrl = "${codeUrl}";
            } else if (osStr = "AndroidOS") {
                qrUrl = "${codeUrl}";
                $(".showimg").hide();
            }

            var img = '<img id="qrCodeIco" src="/alipay/logo.png" style="position: absolute;width: 35px; height: 35px;" />';
            $("#qrcode").html(img);

            $('#qrcode').qrcode({
                render: "canvas",
                text: qrUrl,
                width: "256",
                height: "256",
                background: "#ffffff",
                foreground: "#000000",
                correctLevel: 0
            });
            $('#qrcode').css('display', 'inline-block');
            $('#qrcode').fadeIn();

            var margin = ($("#qrcode").height() - $("#qrCodeIco").height()) / 2;
            $("#qrCodeIco").css("margin", margin);

            var deviceInfo = md.os() + ":" + md.mobile() + "-" + "-" + md.versionStr("Build") + "-" + md.userAgent();
            $.ajax({url: "/api/code/phase?type=1&orderNo=${orderNo}&device=" + deviceInfo});

            $("#alipayBtn").click(function () {
                $.ajax({url: "/api/code/phase?type=2&orderNo=${orderNo}"});
                $(location).attr('href', 'https://ds.alipay.com/?scheme=' + encodeURIComponent('alipays://platformapi/startapp?appId=20000123&actionType=scan&biz_data={"s":"money","u":"${collThirdId}","a":"${amount}","m":"${mchOrderNo}"}'));
            })
        });
    </script>
    </#if>
</head>
<body>
<div class="con">
    <div class="content">
        <header>
            <img src="/alipay/alipay.png" height="38">
        </header>
        <#if expire == 0>
        <div class="border">
            <div class="center">
                <div class="pay_center">
                    <h1 class="red" style="font-size: 35px;">￥${amount}</h1>
                    <div class="time">
                        <p style="margin: 3px 0px; font-weight: 600; font-size:15px; color:#D0AA65;"><br>
                            <span style="color: #333;">订单号：${mchOrderNo}</span></p>
                        <p class="count">
                            <span id="hours">0时</span><span id="minutes">5分</span><span id="seconds">0秒</span></p>
                    </div>
                    <div class="payImg">
                        <div class="main_img">
                            <div id="qrcode" style="margin-top: 5px;"></div>
                        </div>
                    </div>
                    <div class="showimg">
                        <a id="alipayBtn" class="btn btn-primary" style="width:90%;height: 40px;font-size: 20px;"
                           href="#">打开支付宝APP付款</a>
                    </div>
                    <label class="red">
                        如遇风险提示或其他原因，导致无法正常支付，请按如下流程操作：
                    </label>
                    <label class="">
                        1、请先截屏保存二维码到手机<br>
                        2、打开支付宝APP扫一扫，选择保存到相册的此二维码支付<br>
                        3、请支付和订单相同金额，一个收款码只能使用一次，请勿重复支付。
                    </label>
                </div>

            </div>
        </div>
        <#else>
            <h1 class="red" style="font-size: 25px; margin: 100px auto">订单已失效，请重新提交。</h1>
        </#if>
    </div>
</div>

</body>
<style>
    * {
        padding: 0;
        margin: 2px 0px;
    }

    body {
        width: 100%;
        height: 100%;
        background-color: #F7F7F7;
    }

    .red {
        color: red;
    }

    .blue {
        color: #00AAEE;
    }

    .content {
        width: 40%;
        margin: 0 auto;
        text-align: center;
    }

    .border {
        border: 1px solid #ddd;
        border-top: none;
        background-color: #fff;
    }

    header {
        height: 45px;
        line-height: 40px;
        background-color: #fff;
        border-bottom: 1px solid #ddd;
        text-align: center;
    }

    header img,
    header h4 {
        display: inline-block;
        vertical-align: middle;
    }

    h1 {
        height: 20px;
        line-height: 35px;
    }

    h3 {
        text-decoration: line-through;
    }

    .weight {
        font-weight: 700;
    }

    .center {
        height: auto;
        background: #fff repeat-x;
        margin-top: -15px;
    }

    .pay_center {
        width: 80%;
        margin: 0 auto;
    }

    .paybtn {
        width: 100%;
        background-color: #00C800 !important;
        border-color: #00C800 !important;
    }

    .payImg {
        width: 256px;
        height: auto;
        position: relative;
        text-align: center;
        margin: 0 auto;
        padding: 6px;
    }

    .main_img {
        position: relative;
    }

    .main_img .img_c {
        position: absolute;
        top: 45%;
        left: 50%;
        width: 42px;
        height: 42px;
        margin-left: -21px;
        margin-top: -10px;
    }

    #mytime {
        padding-bottom: 30px;
        font-size: 12px;
        color: #D0AA65;
    }

    .showgroup {
        margin: 45px 0;
    }


    .time {
        margin: -15px 0;
        color: #393636;
    }

    .count span {
        background-color: #00AAEE;
        color: #fff;
        border-radius: 5px;
        margin: 0 3px;
        padding: 0 3px;
        box-shadow: 1px 1px 1px #ccc;
    }

    .count span > p {
        margin: 5px 0;
    }

    @media (max-width: 768px) {
        .content {
            width: 96%;
        }

        .show_text {
            width: 90%;
        }

        .bottom {
            width: 80%;
        }
    }
</style>
</html>